<?php
namespace app\adminmall\controller;
use app\adminmall\model\TradeModel;
use app\common\controller\AdminBaseController;
use think\Db;

/**
 * 行业销量统计
 */
class HsalesController extends AdminBaseController {
	protected $model;
	
    protected function _initialize() {
        parent::_initialize();
        $this->model = new TradeModel();
    }
	
	public function index(){
	$grab = Db::name('mall_tradetype')->field('title,id')->buildSql();
	$list = Db::name('mall_order')->alias('c')->field('count(c.id) count,q.title')
	->join($grab. 'q','c.agent_id= q.id','RIGHT')
	->group('q.id')
	->order('count(c.id) DESC')
    ->paginate(10);

		 return $this->fetch('index', ['list' => $list]);
	}	
}
?>